﻿using System.Collections.Generic;
using System.Threading.Tasks;

namespace CkSoftware.GroupMe.Sdk.Core.Interfaces
{
	/// <summary>
	/// Interface for a paged collection.
	/// </summary>
	/// <typeparam name="TEntity">The entity type of a single entry.</typeparam>
	public interface IPagedCollection<out TEntity> : IEnumerable<TEntity>
	{
		/// <summary>
		/// List of all entities fetched.
		/// </summary>
		IEnumerable<TEntity> Entries { get; }

		/// <summary>
		/// List of entities fetched in the last FetchNext call.
		/// </summary>
		IEnumerable<TEntity> NewEntries { get; }

		/// <summary>
		/// Fetches all entities until there are no more entities available.
		/// </summary>
		/// <returns>The awaitable <see cref="Task" />.</returns>
		Task FetchAll();

		/// <summary>
		/// Fetch the next page for the paged entities.
		/// </summary>
		/// <returns>
		/// The result of the fetch, false if there were no more entities fetched, true if there were new entities
		/// available.
		/// </returns>
		Task<bool> FetchNext();
	}
}